package top.zerozoo.learn.grade.vo;

import top.zerozoo.learn.grade.entity.Student;
import top.zerozoo.learn.grade.enums.Sex;
import top.zerozoo.learn.grade.util.NumberUtils;

import java.sql.Date;


public class StudentAddInfo {
    private String name = "未知";
    private String birthday;
    private String sex = "0";
    private String address;
    private String phone;
    private String idcard;
    private String majorID;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getBirthday() {
        return birthday;
    }

    public void setBirthday(String birthday) {
        this.birthday = birthday;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getIdcard() {
        return idcard;
    }

    public void setIdcard(String idcard) {
        this.idcard = idcard;
    }


    public String getMajorID() {
        return majorID;
    }

    public void setMajorID(String majorID) {
        this.majorID = majorID;
    }

    public Student toStudent(){
        Student student = new Student();
        student.setName(name);
        try{
            student.setBirthday(Date.valueOf(birthday));
        }catch (Exception exception){

        }
        student.setSex(Sex.parse(NumberUtils.parse(sex,Integer.class,0)).getNumber());
        student.setAddress(address);
        student.setPhone(phone);
        student.setIdcard(idcard);
        student.setMajorID(NumberUtils.parse(majorID,Integer.class,null));
        return student;
    }

    @Override
    public String toString() {
        return "StudentAddInfo{" +
                "name='" + name + '\'' +
                ", birthday='" + birthday + '\'' +
                ", sex='" + sex + '\'' +
                ", address='" + address + '\'' +
                ", phone='" + phone + '\'' +
                ", idcard='" + idcard + '\'' +
                ", majorID='" + majorID + '\'' +
                '}';
    }
}
